package com.example.sandbox.util;

import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

public class GeneralExecutor {
    @Bean(name = "generalExecutor")
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(30);// 核心线程数
        executor.setMaxPoolSize(30);// 自定义线程数
        executor.setQueueCapacity(5000);// 设置队列容量
        executor.setThreadNamePrefix("generalExecutor-");// 设置线程池中创建的线程的名称前缀
        executor.initialize();
        return executor;
    }


}
